package main

import (
	"flag"
	"log"
	"test_chat/client"
	"test_chat/gui"
)

func main() {
	//var ss server.Server
	//ss = server.NewTcpServer()
	//err := ss.Listen(":3333")
	//if err != nil {
	//	return
	//}
	//time.Sleep(4 * time.Second)
	//go StartClient()
	//ss.Start()

	StartClient()

}

func StartClient() {
	var c client.Client
	log.Println("start client main")
	address := flag.String("server", "127.0.0.1:3333", "server address")
	flag.Parse()
	c = client.NewTcpClient()
	err := c.Dial(*address)
	if err != nil {
		log.Fatal(err)
	}

	defer c.Close()

	go c.Start()

	gui.StartUi(c)

}
